$(function () {
	new fay.ui.menu("#top-menu");
	new fay.ui.Box(".box");
	new fay.ui.ListBox(".list");
	new fay.ui.TitleBox(".titlebox");
	var trig=$("#trigger1");
	if(trig.length>0)
	{
		trig.switchable("#slide1 > div > a", {effect:"scroll",circular: true });
		var sd = trig.switchable();
		var sd_lis = $("#bar1 li");
		sd_lis.click(function () {
			sd.move(sd_lis.index(this));
			sd_lis.removeClass("current");
			$(this).addClass("current");
		});	  
	}	
	$("a").focus(function () {
		if (this.blur) {
			this.blur();
		}
	});
	var bt=$('#subsBt');
	var regex=/^([\w]+)(\.[\w]+)*@([\w\-]+\.){1,5}([A-Za-z]){2,4}$/;	
	bt.click(function() { 
	    var name=$("#subs_name").val();
	    var email=$("#subs_email").val();
	    if( jQuery.trim(name)==='')
	    {
	      alert("Name is required!");
	      return false;
	    }      
	    if( jQuery.trim(email)==='')
	    {
	      alert("Email is required!");
	      return false;
	    }   
	    else
	    {
	       if(!regex.test(email))
	       {
	         alert("Email is not correct.");
	         return false;
	       }
	    }
	    var form=$("#subsForm");
	    form.ajaxForm({success:function(){
	     alert("Thanks for your subscription,we will mail our new Carpets to you.");
	     bt.attr("disabled",false);
	     location.replace(location.href);
	    }});     
	    form.submit();     
	    bt.attr("disabled",true);  
	    
	});	
});

